package org.example;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @ClassName Demo6
 * @Description
 * @Author zhangsw
 * @Date 2020/11/10 10:54
 * @Version 1.0
 */
public class Demo6 {
    public static void main(String[] args) {
        List<Person2> list = new ArrayList<>();
        for (int i = 200; i < 300; i++) {
            Person2 p = new Person2();
            p.setAge(i);
            p.setName("张三" + i);
            p.setPhone("11111111" + i);
            list.add(p);
        }
        List<Person2> pList = list.stream().filter(p -> p.getAge() > 220).collect(Collectors.toList());
        pList.forEach(p -> p.setPhone(getTmPhone(p.getPhone())));
        System.err.println(pList);

        List<Integer> list2 = Arrays.asList(1, 2, 3, 4, 5, 6);
        list2.add(2);
    }

    public static String getTmPhone(String phone) {
        return phone.substring(0, 3) + "****" + phone.substring(7, 11);
    }
}
class Person2 {
    private String name;
    private Integer age;
    private String phone;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    @Override
    public String toString() {
        return "Person2{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", phone='" + phone + '\'' +
                '}';
    }
}
